﻿using TrackSystem.IO.Models;

namespace TrackSystem.IO.Protocol
{
    /// <summary>
    /// 西门子PLC S7-1200通信控制程序
    /// </summary>
    public class S71200Protocol : ProtocolBase
    {
        private string ip;      // ip地址
        private int port;       // PLC站号
        private readonly int dbNumber;  // 寄存器所在的数据块的编号
        private readonly int roAddr;    // 只读寄存器访问的起始地址
        private readonly int roLength;  // 只读寄存器访问的数据长度
        private readonly int rwAddr;    // 读写寄存器访问的起始地址
        private readonly int rwLength;  // 读写寄存器访问的数据长度


        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="name">名称</param>
        /// <param name="ip">IP地址</param>
        /// <param name="port">站号</param>
        /// <param name="station">数据块号</param>
        /// <param name="roAddr">只读寄存器起始地址</param>
        /// <param name="roLength">只读寄存器长度</param>
        /// <param name="rwAddr">读写寄存器起始地址</param>
        /// <param name="rwLength">读写寄存器长度</param>
        public S71200Protocol(string name, string ip, int port, int station, int roAddr, int roLength, int rwAddr, int rwLength)
        {
            this.Name = name;
            this.ip = ip;
            this.port = port;
            this.dbNumber = station;
            this.roAddr = roAddr;
            this.roLength = roLength;
            this.rwAddr = rwAddr;
            this.rwLength = rwLength;
        }

        /// <summary>
        /// 生成读取寄存器的通讯帧
        /// </summary>
        /// <returns></returns>
        public override byte[] GenerateReadFrame(out int NeedRecvLen)
        {
            NeedRecvLen = -1;
            return null;
        }

        /// <summary>
        /// 根据收到的内容进行处理
        /// </summary>
        /// <returns></returns>
        public override bool ProcessReadFrame(byte[] buffer)
        {
            return false;
        }

        /// <summary>
        /// 生成写入寄存器的通讯帧
        /// </summary>
        /// <returns></returns>
        public override byte[] GenerateWriteFrame(out int NeedRecvLen)
        {
            NeedRecvLen = -1;
            return null;
        }

        /// <summary>
        /// 根据收到的内容进行处理
        /// </summary>
        /// <returns></returns>
        public override bool ProcessWriteFrame(byte[] buffer)
        {
            return false; 
        }
    }
}